package com.lishe.lishe.lishe.module.mall.adapter;


import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.lishe.base.common.adapter.base.ItemViewDelegate;
import com.lishe.base.common.adapter.base.ViewHolder;
import com.lishe.base.viewpager.MZBannerView;
import com.lishe.base.viewpager.MZViewHolder;
import com.lishe.lishe.Imageloader.ImageLoaderUtils;
import com.lishe.lishe.R;
import com.lishe.lishe.lishe.module.mall.bean.DataItemBean;
import com.lishe.lishe.lishe.module.mall.bean.GoodsItemsBean;
import com.lishe.lishe.lishe.module.mall.presenter.IndexPresenter;

/**
 * 标    题：
 * 功能描述：
 * 作    者：zouxx
 * 创建时间：2018/8/14
 */

public class BannerItemViewDelegate implements ItemViewDelegate<DataItemBean> {

    private Activity activity;

    public BannerItemViewDelegate(Activity activity) {
        this.activity = activity;
    }

    @Override
    public int getItemViewLayoutId() {
        return R.layout.index_banner_item;
    }

    @Override
    public boolean isForViewType(DataItemBean item, int position) {
        return item.style == 2;
    }

    @Override
    public void convert(ViewHolder holder, DataItemBean dataBean, int position) {
        ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        holder.itemView.setLayoutParams(params);
        MZBannerView mzBannerView = holder.getView(R.id.index_banner);
        mzBannerView.setDelayedTime(5000);
        mzBannerView.setPages(dataBean.list, BannerImageHolder::new);
        mzBannerView.start();
        mzBannerView.setBannerPageClickListener((view, position1) -> {
            IndexPresenter.setOnClick(activity, dataBean.list.get(position1));
        });
    }
}
